package com.microbroadcast.resource.manager;

import java.util.List;

import com.microbroadcast.DAO.MessagePersistence;
import com.microbroadcast.exception.ErrorInputException;
import com.microbroadcast.resource.Message;

/*
 * Written by pansen at 2013/04/17
 */

public class MessageManager {
	public static List<Message> getMessage(long areaID, long sinceID,
			long maxID, int num) throws ErrorInputException {
		List<Message> result = null;
		if (sinceID == -1) {
			if (maxID == -1) {
				result = MessagePersistence.getMessageList(areaID, num);
			} else {
				result = MessagePersistence.getMessageListBefore(areaID, num, maxID);
			}
		} else {
			if (maxID == -1) {
				result = MessagePersistence.getMessageListAfter(areaID, num, sinceID);
			} else {
				throw new ErrorInputException();
			}
		}
		return result;
	}
}